package org.paic.vertx.utils;

import java.util.List;

@SuppressWarnings("rawtypes")
public class Pager {
	private int pageNum = 1;
	private int pageSize = 10;
	private int totalCount = 0;

	private List ll;

	public List getLl() {
		return ll;
	}

	public void setLl(List ll) {
		this.ll = ll;
	}

	public Pager(int c, int n) {
		pageNum = c;
		pageSize = n;
	}

	public int getTotalPage() {
		return (totalCount % pageSize == 0) ? totalCount / pageSize
				: (totalCount / pageSize + 1);
	}

	public int getStart() {
		return (pageNum - 1) * pageSize;
	}

	public int getEnd() {
		if (totalCount < pageSize || pageNum == getStart())
			return totalCount;
		else
			return pageNum * pageSize;
	}

	public boolean hasNext() {
		return pageNum < getTotalPage();
	}

	public int getPageNum() {
		return pageNum;
	}

	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(int totalCount) {
		this.totalCount = totalCount;
	}

	public boolean hasPre() {
		return pageNum > 1 && getPageNum() > 1;
	}
}
